package org.hdax.dm.controller;

import com.netflix.discovery.converters.Auto;
import org.hdax.dm.entity.itemComment.DmItemComment;
import org.hdax.dm.request.QueryItemComment;
import org.hdax.dm.request.QueryItemRecommendRequest;
import org.hdax.dm.request.QueryItemDetailRequest;
import org.hdax.dm.service.DmCinemaService;
import org.hdax.dm.service.DmItemCommentService;
import org.hdax.dm.service.DmItemService;
import org.hdax.dm.vo.CommonResponse;
import org.hdax.dm.vo.entity.item.VoQueryItemComment;
import org.hdax.dm.vo.entity.item.VoQueryItemDetail;
import org.hdax.dm.vo.entity.item.VoQueryItemRecommend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping
public class CommodityConstoller {

    @Autowired
    private DmItemService dmItemService;
    @Autowired
    private DmItemCommentService dmItemCommentService;

    /**
     * 根据商品id返回商品详情页
     */
    @PostMapping(path = "/p/queryItemDetail")
    @ResponseBody
    public CommonResponse<VoQueryItemDetail> queryItemDetail(@RequestBody QueryItemDetailRequest queryItemDetailRequest) {
        return dmItemService.queryItemDetail(queryItemDetailRequest.getId());
    }

    /**
     * 根据商品id查询剧评
     */
    @PostMapping(path = "/p/queryItemComment")
    @ResponseBody
    public CommonResponse<List<VoQueryItemComment>> queryItemComment(@RequestBody QueryItemComment queryItemComment) {
        return dmItemCommentService.queryItemComment(queryItemComment);
    }

    /**
     * 添加剧评
     */
    @PostMapping(path = "/v/commitItemComment")
    @ResponseBody
    public CommonResponse commitItemComment(@RequestBody DmItemComment dmItemComment) {
        return dmItemCommentService.commitItemComment(dmItemComment);
    }

    /**
     * 推荐接口
     */
    @PostMapping(path = "/p/queryItemRecommend")
    @ResponseBody
    public CommonResponse<List<VoQueryItemRecommend>> queryItemRecommend(@RequestBody QueryItemRecommendRequest queryItemRecommendRequest) {
        return dmItemService.queryItemRecommend(queryItemRecommendRequest.getItemTypeId());
    }

}
